/**
 * 
 */
package fhq.hcmute.edu.vn.system;

/**
 * @author Hien Nguyen Oct 30, 2012
 */
public class MyFile extends MySystem {
	private static final long serialVersionUID = 86144041725254330L;

	@Override
	public void add(MySystem myDisk) {
		throw new UnsupportedOperationException();
	}

	public MyFile() {
	}

	public MyFile(MyFile myFile) {
		this.name = myFile.name;
		this.path = myFile.path;
		this.isHidden = myFile.isHidden;
		this.fileType = getFileExtension(name);
		this.iconUrl = fileType.getValue();
	}

	public MyFile(String name, String path, Boolean isHidden) {
		this.name = name;
		this.path = path;
		this.isHidden = isHidden;
		this.fileType = getFileExtension(name);
		this.iconUrl = fileType.getValue();
	}

	private FileType getFileExtension(String fileName) {
		String ext = fileName.substring(fileName.lastIndexOf(".") + 1);
		return FileType.fromString(ext);
	}
}
